using System.Collections.Generic;
using System.Text;
using System;
using NHibernate;
using NHibernate.Cfg;
using JVLMRP;
namespace JVLMRP 
{
    public class MRPDetailsExportService
    {
        ISession session;

        public MRPDetailsExportService(ISession session)
        {
            this.session = session;
        }
        public MRPDetailsExportService()
        {
            this.session = SessionFactory.GetNewSession();
        }
        public void InsertMrpdetailsexport(MRPDetailsExport mrpdetailsexportX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Save(mrpdetailsexportX);
            tx.Commit();
        }

        public void UpdateMrpdetailsexport(MRPDetailsExport mrpdetailsexportX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Update(mrpdetailsexportX);
            tx.Commit();
        }

        public void DeleteMrpdetailsexport(MRPDetailsExport mrpdetailsexportX)
        {
            ITransaction tx = session.BeginTransaction();
            session.Delete(mrpdetailsexportX);
            tx.Commit();
        }

        public IList<MRPDetailsExport> GetAllMrpdetailsexport(Boolean evict)
        {
            IQuery query = session.CreateQuery("select from MRPDetailsExport");
            IList<MRPDetailsExport> list = query.List<MRPDetailsExport>();
            if (evict)
            {
                foreach (MRPDetailsExport s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }

        public MRPDetailsExport GetAllMrpdetailsexportByID(String id, Boolean evict)
        {
            IQuery query = session.CreateQuery("select c from MRPDetailsExport as c where c.Detailsexportid= :x");
            query.SetString("x", id);
            MRPDetailsExport s = (MRPDetailsExport)query.UniqueResult();
            if (evict)
            {
                session.Evict(s);
            }
            return s;
        }

        public IList<MRPDetailsExport> GetMrpdetailsexportByQuery(IQuery query, Boolean evict)
        {
            IList<MRPDetailsExport> list = query.List<MRPDetailsExport>();
            if (evict)
            {
                foreach (MRPDetailsExport s in list)
                {
                    session.Evict(s);
                }
            }
            return list;
        }
    }
}
